package com.abc.test.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;


public class UserDAO 
{
	public static void main(String[] args)
	{
		UserDAO udao = new UserDAO();
	    Boolean bl = udao.login("test","test");
	    
	    System.out.println(bl.toString());
	}
	
	public Boolean login(String username,String userpwd)
	{
		try 
		{
			Class.forName("com.mysql.jdbc.Driver");
			Connection conn  =  DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root" ,"123456" );
			
			Statement stm = conn.createStatement();
			ResultSet rs = stm.executeQuery("select * from test_user where username='" + username +"' and userpwd = '" + userpwd + "'");
			if (rs.first())
			{
				return true;
			}
			else
			{
				return false;
			}
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
			return false;
		}		
	}
}
